home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / mgr.trm < prev    next >
Text File  |  1993-09-15  |  3KB  |  149 lines

  1. /* GNUPLOT - mgr.trm */
  2. /*
  3.  * This file is included by ../term.c.
  4.  *
  5.  * This terminal driver supports:
  6.  *  Mgr window system, color display
  7.  *
  8.  * AUTHOR
  9.  *  Vincent Broman, broman@nosc.mil
  10.  */
  11.  
  12. #undef ESC
  13. #include <term.h>    /* from Mgr, not gnuplot */
  14.  
  15.  
  16. #define MGR_XMAX 640
  17. #define MGR_YMAX 400
  18. #define MGR_VCHAR 16
  19. #define MGR_HCHAR 8
  20. #define MGR_VTIC 4
  21. #define MGR_HTIC 4
  22.  
  23. static int MGR_border = 5;
  24. static int MGR_winnbr = 0;
  25.  
  26. static int MGR_rowcount = 24;
  27. static int MGR_winwidth = MGR_XMAX;
  28. static int MGR_winheight = MGR_YMAX;
  29. static int MGR_vchar = MGR_VCHAR;
  30. static int MGR_hchar = MGR_HCHAR;
  31.  
  32.  
  33. MGR_init()
  34. {
  35. char res[300];
  36. int winnbr;
  37. int w, h, bor;
  38.  
  39.     m_setup( 0);
  40.     m_ttyset();
  41.  
  42.     m_getinfo( G_SYSTEM);
  43.     if( m_gets( res) && sscanf( res, "%*s%d%d%d", &w, &h, &bor) == 3)
  44.         MGR_border = bor;
  45.  
  46.     m_newwin( 0, 0, MGR_winwidth+2*MGR_border, MGR_winheight+2*MGR_border);
  47.     if( m_gets( res) && sscanf( res, "%d", &winnbr) == 1)
  48.         MGR_winnbr = winnbr;
  49.         /* if no alt window is created, then the main window is used */
  50.         /* and if size is different, term_tbl updated later */
  51.     m_selectwin( MGR_winnbr);
  52.     m_setmode( M_ABS);
  53.  
  54.     m_getinfo( G_FONT);
  55.     if( m_gets( res) && sscanf( res, "%d %d", &w, &h) == 2) {
  56.         MGR_vchar = h;
  57.         MGR_hchar = w;
  58.     }
  59.     m_ttyreset();
  60.  
  61.     term_tbl[term].v_char = MGR_vchar;
  62.     term_tbl[term].h_char = MGR_hchar;
  63.     term_tbl[term].v_tic = MGR_vchar / 4;
  64.     term_tbl[term].h_tic = MGR_hchar / 2;
  65.  
  66.     m_selectwin( 0);
  67.     m_flush();
  68. }
  69.  
  70.  
  71. MGR_graphics()
  72. {
  73. char res[32];
  74. int c, r, w, h;
  75.  
  76.     m_selectwin( MGR_winnbr);
  77.     m_setmode( M_ACTIVATE);
  78.     m_clear();
  79.  
  80.     /* we permit the user to reshape the window arbitrarily.
  81.        do_plot calls boundary to recheck the term_tbl for each plot */
  82.     m_ttyset();
  83.     m_getinfo( G_WINSIZE);
  84.     if( m_gets( res) && sscanf( res, "%d %d", &c, &r) == 2)
  85.         MGR_rowcount = r;
  86.     m_getinfo( G_COORDS);
  87.     if( m_gets( res) && sscanf( res, "%d %d %d %d", &c, &r, &w, &h) == 4) {
  88.         term_tbl[term].xmax = MGR_winwidth = w;
  89.         term_tbl[term].ymax = MGR_winheight = h;
  90.     }
  91.     m_ttyreset();
  92.     m_flush();
  93. }
  94.  
  95.  
  96. MGR_text()
  97. {
  98.     m_go( 0, 0);
  99.     m_aligntext();
  100.     if( MGR_winnbr == 0)
  101.         m_move( 0, MGR_rowcount - 1);
  102.     m_selectwin( 0);
  103.     m_flush();
  104. }
  105.  
  106.  
  107. MGR_linetype( linetype)
  108. int     linetype;
  109. {
  110. /*
  111.  * this mapping of colors is intended for a color sun on which
  112.  * colors 0-23 are defined, 0 is white, 1 is black.
  113.  */
  114.     m_linecolor( B_SRC, (linetype < 0)? 1: (2 + (linetype % 22)));
  115. }
  116.  
  117.  
  118. MGR_move( x, y)
  119. int x, y;
  120. {
  121.     m_go( x, MGR_winheight - 1 - y);
  122. }
  123.  
  124.  
  125. MGR_vector( x, y)
  126. int x, y;
  127. {
  128.     m_draw( x, MGR_winheight - 1 - y);
  129. }
  130.  
  131.  
  132. MGR_put_text( x, y, str)
  133. int x, y;
  134. char *str;
  135. {
  136.     MGR_move( x, y - MGR_vchar/2);
  137.     m_aligntext();
  138.     m_printstr( str);
  139. }
  140.  
  141.  
  142. MGR_reset()
  143. {
  144.     m_destroywin( MGR_winnbr);
  145.     MGR_winnbr = 0;
  146.     m_setmode( M_ACTIVATE);
  147.     m_flush();
  148. }
  149.